package com.engine4cloud.tdf.supervision.convert;

import com.engine4cloud.tdf.supervision.dto.create.JzdxAuditAcceptCreateDTO;
import com.engine4cloud.tdf.supervision.dto.create.JzdxAuditAssignCreateDTO;
import com.engine4cloud.tdf.supervision.dto.result.JzdxReportReceiveCaseResultDTO;
import com.engine4cloud.tdf.supervision.entity.JzdxReportReceiveCaseEntity;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.time.LocalDate;

@Mapper
public interface JzdxReportReceiveConvert {
    JzdxReportReceiveConvert INSTANCE = Mappers.getMapper(JzdxReportReceiveConvert.class);

    JzdxReportReceiveCaseEntity createTo(JzdxAuditAssignCreateDTO s, Long tenantId);

    JzdxReportReceiveCaseEntity updateTo(JzdxAuditAcceptCreateDTO s);

    JzdxReportReceiveCaseEntity updateTo(JzdxAuditAssignCreateDTO s);

    JzdxReportReceiveCaseResultDTO convert(JzdxReportReceiveCaseEntity s);

    default JzdxReportReceiveCaseEntity create(JzdxAuditAssignCreateDTO s, Long tenantId) {
        JzdxReportReceiveCaseEntity entity = createTo(s, tenantId);
        entity.setSqjzryjsrq(s.getReceiveCase().getSqjzryjsrq());
        entity.setSqjzryjsfs(s.getReceiveCase().getSqjzryjsfs());
        entity.setTenantId(tenantId);
        return entity;
    }

    default JzdxReportReceiveCaseEntity update(JzdxAuditAcceptCreateDTO s, Long id) {
        JzdxReportReceiveCaseEntity entity = updateTo(s);
        entity.setId(id);
        entity.setBdqk(s.getReceiveCase().getBdqk());
        entity.setSqjzrysjjsrq(LocalDate.now());
        entity.setWasbdqksm(s.getReceiveCase().getWasbdqksm());
        return entity;
    }

    default JzdxReportReceiveCaseEntity update(JzdxAuditAssignCreateDTO s, Long id) {
        JzdxReportReceiveCaseEntity entity = updateTo(s);
        entity.setId(id);
        entity.setSqjzrysjjsrq(LocalDate.now());
        return entity;
    }
}
